<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:a4j="http://richfaces.org/a4j">
	
<ui:composition template="/layout/template.xhtml">
    
<ui:define name="body">
<a4j:form id="intimacaoSearch" styleClass="edit">

<div class="bodyPage container_16">
	
    <div class="grid_16">
    
    	<div class="breadCrumb">
        	<p><span>Você está em:</span> Pesquisar  >  Paciente</p>
        </div>
    	
        <div>
            <h1>Pesquisa de Pacientes</h1>
            <div class="grid_9 btns">
                <ul>
                    <li><s:link view="/paciente/CadastroPaciente.xhtml" value="Adicionar Paciente" styleClass="btnAdicionar" action="#{pacienteAction.inicializaPaciente}"/></li>
                </ul>
            </div>
        </div>
        
    	<div class="boxForm">
        	<fieldset>
            	<legend>Dados do Paciente</legend>
                <ul>
                	<li>
                    	<label class="grid_3">Nome do paciente:</label>
                        <span class="grid_12 campo">
                        	<h:inputText value="#{pacienteAction.nomePaciente}" styleClass="full"/>
                        </span>
                        
                        <div class="grid_12 campo">
	                        <a4j:commandButton action="#{pacienteAction.buscarPaciente}" image="/img/search.png" reRender="listPacientes" style="border:none;">
			        	 		<a4j:status id="loading"  
								            onstart="Richfaces.showModalPanel('panel_loading')"   
								            onstop="Richfaces.hideModalPanel('panel_loading')" >  
					        	</a4j:status>
			        	 	</a4j:commandButton>
                        </div>
                    </li>
                </ul>
            </fieldset>
        </div>
        
        <div class="contentGeral">
            <h2>Resultado da Pesquisa:</h2>
            <div class="grid_9 btns">
        </div>
            
            <div>
            	<table class="full">
         			<rich:dataTable id="listPacientes"
         				value="#{pacienteAction.pacientes.toArray()}"
         				var="_paciente" onRowMouseOver="this.style.backgroundColor='#9AFF9A'"
                		onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
               			cellpadding="0" cellspacing="0">
         			
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Nome" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.nome}" />
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
				           	  	  <h:outputText value="CPF" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.cpf}" />
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Cidade" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.cidade}" />
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Telefone Fixo" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.foneFixo}" />
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Telefone Celular" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.foneCelular}" />
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Email" />
				  		      </f:facet>
				 				<h:outputText value="#{_paciente.email}" />
				 		</rich:column>
				 		
				 		<rich:column>
					        	<f:facet name="header">
					                <h:outputText value="Ações" />
					            </f:facet>
					            #{' '}						            
					      				 <a4j:commandLink ajaxSingle="true" id="editlink"
						                        		  action="#{pacienteAction.carregarPaciente}">
						                        <f:setPropertyActionListener target="#{pacienteAction.paciente}" value="#{_paciente}" />
						                        <h:graphicImage value="../img/edit_icon.png" style="border:0"/>
					                    </a4j:commandLink>					            
				   					    
				   					    <a4j:commandLink ajaxSingle="true" id="deletelink"
					                        			action="#{pacienteAction.excluiPaciente}" reRender="listPacientes">
					                        <f:setPropertyActionListener target="#{pacienteAction.paciente}" value="#{_paciente}" />
					                        <h:graphicImage value="../img/close.png" style="border:0" />
					                    </a4j:commandLink>
					        </rich:column>
				         			
				     </rich:dataTable>
                </table>
            </div>
            
        </div>
		
    </div>
    
</div><!-- #bodyPage -->

		<rich:modalPanel id="panel_loading" autosized="true">
			<h:graphicImage url="/img/loading.gif" style="border:0px; vertical-align: middle;" />
				<rich:spacer width="20" /><br/>
				<h:outputText value="Carregando... Aguarde!" />
		</rich:modalPanel>
	
		<rich:modalPanel id="editPanel" autosized="true" width="600" >
	
		<f:facet name="header">
            <h:outputText value="Editar Consulta" />
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="../img/close.png" id="hidelink"
                    styleClass="hidelink" />
                <rich:componentControl for="editPanel" attachTo="hidelink"
                    operation="hide" event="onclick" />
            </h:panelGroup>
        </f:facet>
        <h:form>


           	<!--h:form>
            	<ui:include src="/paciente/GeralForm.xhtml" />
            </h:form-->
        </h:form>
        
	</rich:modalPanel>
	
	<rich:modalPanel id="deletePanel" autosized="true" width="200">
        <f:facet name="header">
            <h:outputText value="Deseja deletar esse registro?"
                style="padding-right:15px;" />
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="../img/close.png"
                    styleClass="hidelink" id="hidelink2" />
                <rich:componentControl for="deletePanel" attachTo="hidelink2"
                    operation="hide" event="onclick" />
            </h:panelGroup>
        </f:facet>
        <h:form>
            <table width="100%">
                <tbody>
                    <tr>
                        <td align="center" width="50%"><a4j:commandButton value="Yes"
                            ajaxSingle="true"
                            oncomplete="#{rich:component('deletePanel')}.hide();"
                            reRender="table"/></td>
                        <td align="center" width="50%"><a4j:commandButton
                            value="Cancel"
                            onclick="#{rich:component('deletePanel')}.hide();return false;" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </h:form>
    </rich:modalPanel>
    
</a4j:form>
</ui:define>    
</ui:composition>    
</html>